package Views;

import Controllers.CustomerCTR;
import Models.Customer;
import Views.TableModels.CustomerTableModel;
import byggemarked.Tools;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JOptionPane;

/**
 * @author Tanja
 */
public class CustomerView extends javax.swing.JFrame
{
	private CustomerCTR controller = new CustomerCTR();

    public CustomerView() {
        initComponents();
		findTable.addMouseListener(new MouseAdapter(){
			@Override
			public void mouseClicked(MouseEvent e){
				if (e.getClickCount() == 2)
				{
					if(findTable.getSelectedRowCount() == 1)
					{
						int chosenId = Integer.parseInt(findTable.getValueAt(findTable.getSelectedRow(), 0).toString());
						new CustomerInfoView(controller.getCustomer(chosenId)).setVisible(true);
					}
				}
			}
		 });
    }

	@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        customerBG = new javax.swing.ButtonGroup();
        customerTabbedPane1 = new javax.swing.JTabbedPane();
        addCustomerPanel = new java.awt.Panel();
        addDescriptionLabel = new javax.swing.JLabel();
        addPrivateCustomerLabel = new javax.swing.JLabel();
        privateCustomerRB = new javax.swing.JRadioButton();
        businessCustomerRB = new javax.swing.JRadioButton();
        addPrivateNameLabel = new javax.swing.JLabel();
        addPrivateNameTF = new javax.swing.JTextField();
        addBusinessNameLabel = new javax.swing.JLabel();
        addBusinessNameTF = new javax.swing.JTextField();
        addCvrLabel = new javax.swing.JLabel();
        addCvrSpinner = new javax.swing.JSpinner();
        addContactLabel = new javax.swing.JLabel();
        addContactTF = new javax.swing.JTextField();
        addAddressLabel = new javax.swing.JLabel();
        addAddressTF = new javax.swing.JTextField();
        addZipCodeLabel = new javax.swing.JLabel();
        addZipCodeSpinner = new javax.swing.JSpinner();
        addCityLabel = new javax.swing.JLabel();
        addCityTF = new javax.swing.JTextField();
        addPhoneNoLabel = new javax.swing.JLabel();
        addPhoneNoSpinner = new javax.swing.JSpinner();
        addButton = new javax.swing.JButton();
        findCustomerPanel = new java.awt.Panel();
        findDescriptionLabel = new javax.swing.JLabel();
        findCustomerLabel = new javax.swing.JLabel();
        findCustomerNameTF = new javax.swing.JTextField();
        findContactLabel = new javax.swing.JLabel();
        findContactTF = new javax.swing.JTextField();
        findCvrLabel = new javax.swing.JLabel();
        findAddressLabel = new javax.swing.JLabel();
        findAddressTF = new javax.swing.JTextField();
        findCvrSpinner = new javax.swing.JSpinner();
        findZipCodeLabel = new javax.swing.JLabel();
        findZipCodeSpinner = new javax.swing.JSpinner();
        findCityLabel = new javax.swing.JLabel();
        findCityTF = new javax.swing.JTextField();
        findPhoneNoLabel = new javax.swing.JLabel();
        findPhoneNoSpinner = new javax.swing.JSpinner();
        findButton = new javax.swing.JButton();
        findShowAllButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        findTable = new javax.swing.JTable();
        getCustomerPanel = new java.awt.Panel();
        getCustomerLabel = new javax.swing.JLabel();
        getIDLabel = new javax.swing.JLabel();
        getIDSpinner = new javax.swing.JSpinner();
        getButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Kunder");

        addDescriptionLabel.setText("Her kan der tilføjes kunder. Vælg først kundetypen");

        addPrivateCustomerLabel.setText("Vælg kundetype:");

        customerBG.add(privateCustomerRB);
        privateCustomerRB.setSelected(true);
        privateCustomerRB.setText("Privatkunder");
        privateCustomerRB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                privateCustomerRBActionPerformed(evt);
            }
        });

        customerBG.add(businessCustomerRB);
        businessCustomerRB.setText("Erhvervskunder");
        businessCustomerRB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                businessCustomerRBActionPerformed(evt);
            }
        });

        addPrivateNameLabel.setText("Navn:");

        addBusinessNameLabel.setText("Firmanavn:");

        addBusinessNameTF.setEnabled(false);

        addCvrLabel.setText("CVR:");

        addCvrSpinner.setEnabled(false);

        addContactLabel.setText("Kontaktperson:");

        addContactTF.setEnabled(false);

        addAddressLabel.setText("Adresse:");

        addZipCodeLabel.setText("Postnr:");

        addCityLabel.setText("By:");

        addPhoneNoLabel.setText("Telefonnummer:");

        addButton.setText("Tilføj");
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout addCustomerPanelLayout = new org.jdesktop.layout.GroupLayout(addCustomerPanel);
        addCustomerPanel.setLayout(addCustomerPanelLayout);
        addCustomerPanelLayout.setHorizontalGroup(
            addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(addCustomerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, addDescriptionLabel)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, addCustomerPanelLayout.createSequentialGroup()
                            .add(addPrivateCustomerLabel)
                            .add(18, 18, 18)
                            .add(privateCustomerRB)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(businessCustomerRB))
                        .add(addButton)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, addContactLabel)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, addCustomerPanelLayout.createSequentialGroup()
                                .add(addPrivateNameLabel)
                                .add(77, 77, 77)
                                .add(addPrivateNameTF))
                            .add(org.jdesktop.layout.GroupLayout.LEADING, addCustomerPanelLayout.createSequentialGroup()
                                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(addBusinessNameLabel)
                                    .add(addCvrLabel))
                                .add(44, 44, 44)
                                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, addCvrSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 162, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, addCustomerPanelLayout.createSequentialGroup()
                                        .add(1, 1, 1)
                                        .add(addContactTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 231, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, addBusinessNameTF)))))
                    .add(addZipCodeLabel)
                    .add(addCustomerPanelLayout.createSequentialGroup()
                        .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(addPhoneNoLabel)
                            .add(addAddressLabel))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(addPhoneNoSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 140, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, addCustomerPanelLayout.createSequentialGroup()
                                    .add(1, 1, 1)
                                    .add(addAddressTF))
                                .add(org.jdesktop.layout.GroupLayout.LEADING, addCustomerPanelLayout.createSequentialGroup()
                                    .add(addZipCodeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(addCityLabel)
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(addCityTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 157, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        addCustomerPanelLayout.setVerticalGroup(
            addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(addCustomerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(addDescriptionLabel)
                .add(18, 18, 18)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addPrivateCustomerLabel)
                    .add(privateCustomerRB)
                    .add(businessCustomerRB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addPrivateNameLabel)
                    .add(addPrivateNameTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(34, 34, 34)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addBusinessNameLabel)
                    .add(addBusinessNameTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addCvrLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 18, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(addCvrSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addContactLabel)
                    .add(addContactTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 37, Short.MAX_VALUE)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addAddressLabel)
                    .add(addAddressTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addZipCodeLabel)
                    .add(addZipCodeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(addCityLabel)
                    .add(addCityTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(9, 9, 9)
                .add(addCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addPhoneNoSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(addPhoneNoLabel))
                .add(27, 27, 27)
                .add(addButton)
                .addContainerGap())
        );

        customerTabbedPane1.addTab("Tilføj", addCustomerPanel);

        findDescriptionLabel.setText("Det er muligt at søge på forskellige kriterier for kunderne");

        findCustomerLabel.setText("Navn eller firmanavn:");

        findContactLabel.setText("Kontaktperson (kun firma):");

        findCvrLabel.setText("CVR (kun firma):");

        findAddressLabel.setText("Adresse:");

        findZipCodeLabel.setText("Postnummer:");

        findCityLabel.setText("By:");

        findPhoneNoLabel.setText("Telefonnummer:");

        findButton.setText("Søg");
        findButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                findButtonActionPerformed(evt);
            }
        });

        findShowAllButton.setText("Vis alle");
        findShowAllButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                findShowAllButtonActionPerformed(evt);
            }
        });

        findTable.setModel(new CustomerTableModel());
        jScrollPane1.setViewportView(findTable);

        org.jdesktop.layout.GroupLayout findCustomerPanelLayout = new org.jdesktop.layout.GroupLayout(findCustomerPanel);
        findCustomerPanel.setLayout(findCustomerPanelLayout);
        findCustomerPanelLayout.setHorizontalGroup(
            findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(findCustomerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                    .add(findCustomerPanelLayout.createSequentialGroup()
                        .add(findButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(findShowAllButton))
                    .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, findCustomerPanelLayout.createSequentialGroup()
                            .add(findCustomerLabel)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(findCustomerNameTF))
                        .add(org.jdesktop.layout.GroupLayout.LEADING, findDescriptionLabel))
                    .add(findCustomerPanelLayout.createSequentialGroup()
                        .add(findZipCodeLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(findZipCodeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 62, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(findCityLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(findCityTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 180, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(findCustomerPanelLayout.createSequentialGroup()
                        .add(findPhoneNoLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(findPhoneNoSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(findCustomerPanelLayout.createSequentialGroup()
                        .add(findAddressLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(findAddressTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 222, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(findCustomerPanelLayout.createSequentialGroup()
                        .add(findContactLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(findContactTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 203, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(findCustomerPanelLayout.createSequentialGroup()
                        .add(findCvrLabel)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(findCvrSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 134, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        findCustomerPanelLayout.setVerticalGroup(
            findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(findCustomerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(findDescriptionLabel)
                .add(18, 18, 18)
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(findCustomerLabel)
                    .add(findCustomerNameTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(findContactLabel)
                    .add(findContactTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(findCvrLabel)
                    .add(findCvrSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(22, 22, 22)
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(findAddressLabel)
                    .add(findAddressTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(findZipCodeLabel)
                    .add(findZipCodeSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(findCityLabel)
                    .add(findCityTF, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(findPhoneNoLabel)
                    .add(findPhoneNoSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(findCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(findButton)
                    .add(findShowAllButton))
                .add(12, 12, 12)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        customerTabbedPane1.addTab("Søg", findCustomerPanel);

        getCustomerLabel.setText("Her kan der søges på kunders ID");

        getIDLabel.setText("ID:");

        getButton.setText("Hent");
        getButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                getButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout getCustomerPanelLayout = new org.jdesktop.layout.GroupLayout(getCustomerPanel);
        getCustomerPanel.setLayout(getCustomerPanelLayout);
        getCustomerPanelLayout.setHorizontalGroup(
            getCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(getCustomerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(getCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(getCustomerLabel)
                    .add(getCustomerPanelLayout.createSequentialGroup()
                        .add(getIDLabel)
                        .add(18, 18, 18)
                        .add(getIDSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(getButton))
                .addContainerGap(196, Short.MAX_VALUE))
        );
        getCustomerPanelLayout.setVerticalGroup(
            getCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(getCustomerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(getCustomerLabel)
                .add(18, 18, 18)
                .add(getCustomerPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(getIDLabel)
                    .add(getIDSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(getButton)
                .addContainerGap(348, Short.MAX_VALUE))
        );

        customerTabbedPane1.addTab("Hent", getCustomerPanel);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(customerTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, customerTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

	private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
		int zipCode = Integer.parseInt(addZipCodeSpinner.getValue().toString());
		int phoneNo = Integer.parseInt(addPhoneNoSpinner.getValue().toString());
		int cvr = Integer.parseInt(addCvrSpinner.getValue().toString());
		Customer customer = null;
		if(privateCustomerRB.isSelected())
		{
			customer = this.controller.addPrivateCustomer(
										addPrivateNameTF.getText(),
										addAddressTF.getText(),
										zipCode,
										addCityTF.getText(),
										phoneNo);
		}
		else
		{
			customer = this.controller.addBusinessCustomer(
										addBusinessNameTF.getText(),
										addContactTF.getText(),
										cvr,
										addAddressTF.getText(),
										zipCode,
										addCityTF.getText(),
										phoneNo);
		}
		JOptionPane.showMessageDialog(this, "Kunden '"+Tools.getNameOrCompanyName(customer)+"' er tilføjet til kartoteket.", "Kunden er tilføjet", JOptionPane.INFORMATION_MESSAGE);
	}//GEN-LAST:event_addButtonActionPerformed

	private void getButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getButtonActionPerformed
		Customer customer = this.controller.getCustomer(Integer.parseInt(getIDSpinner.getValue().toString()));
		new CustomerInfoView(customer).setVisible(true);
}//GEN-LAST:event_getButtonActionPerformed

	private void findButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findButtonActionPerformed
		int zipCode = Integer.parseInt(findZipCodeSpinner.getValue().toString());
		int phoneNo = Integer.parseInt(findPhoneNoSpinner.getValue().toString());
		int cvr = Integer.parseInt(findCvrSpinner.getValue().toString());
		findTable.setModel(
				new CustomerTableModel(
					this.controller.findCustomer(
						findAddressTF.getText(),
						zipCode,
						findCityTF.getText(),
						phoneNo,
						findCustomerNameTF.getText(),
						findContactTF.getText(),
						cvr)));
	}//GEN-LAST:event_findButtonActionPerformed

	private void privateCustomerRBActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_privateCustomerRBActionPerformed
	{//GEN-HEADEREND:event_privateCustomerRBActionPerformed
		addPrivateNameTF.setEnabled(true);
		addBusinessNameTF.setText("");
		addBusinessNameTF.setEnabled(false);
		addCvrSpinner.setValue(0);
		addCvrSpinner.setEnabled(false);
		addContactTF.setText("");
		addContactTF.setEnabled(false);
	}//GEN-LAST:event_privateCustomerRBActionPerformed

	private void businessCustomerRBActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_businessCustomerRBActionPerformed
	{//GEN-HEADEREND:event_businessCustomerRBActionPerformed
		addBusinessNameTF.setEnabled(true);
		addCvrSpinner.setEnabled(true);
		addContactTF.setEnabled(true);
		addPrivateNameTF.setText("");
		addPrivateNameTF.setEnabled(false);
	}//GEN-LAST:event_businessCustomerRBActionPerformed

	private void findShowAllButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_findShowAllButtonActionPerformed
	{//GEN-HEADEREND:event_findShowAllButtonActionPerformed
		findTable.setModel(new CustomerTableModel(this.controller.getAllCustomers()));
	}//GEN-LAST:event_findShowAllButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel addAddressLabel;
    private javax.swing.JTextField addAddressTF;
    private javax.swing.JLabel addBusinessNameLabel;
    private javax.swing.JTextField addBusinessNameTF;
    private javax.swing.JButton addButton;
    private javax.swing.JLabel addCityLabel;
    private javax.swing.JTextField addCityTF;
    private javax.swing.JLabel addContactLabel;
    private javax.swing.JTextField addContactTF;
    private java.awt.Panel addCustomerPanel;
    private javax.swing.JLabel addCvrLabel;
    private javax.swing.JSpinner addCvrSpinner;
    private javax.swing.JLabel addDescriptionLabel;
    private javax.swing.JLabel addPhoneNoLabel;
    private javax.swing.JSpinner addPhoneNoSpinner;
    private javax.swing.JLabel addPrivateCustomerLabel;
    private javax.swing.JLabel addPrivateNameLabel;
    private javax.swing.JTextField addPrivateNameTF;
    private javax.swing.JLabel addZipCodeLabel;
    private javax.swing.JSpinner addZipCodeSpinner;
    private javax.swing.JRadioButton businessCustomerRB;
    private javax.swing.ButtonGroup customerBG;
    private javax.swing.JTabbedPane customerTabbedPane1;
    private javax.swing.JLabel findAddressLabel;
    private javax.swing.JTextField findAddressTF;
    private javax.swing.JButton findButton;
    private javax.swing.JLabel findCityLabel;
    private javax.swing.JTextField findCityTF;
    private javax.swing.JLabel findContactLabel;
    private javax.swing.JTextField findContactTF;
    private javax.swing.JLabel findCustomerLabel;
    private javax.swing.JTextField findCustomerNameTF;
    private java.awt.Panel findCustomerPanel;
    private javax.swing.JLabel findCvrLabel;
    private javax.swing.JSpinner findCvrSpinner;
    private javax.swing.JLabel findDescriptionLabel;
    private javax.swing.JLabel findPhoneNoLabel;
    private javax.swing.JSpinner findPhoneNoSpinner;
    private javax.swing.JButton findShowAllButton;
    private javax.swing.JTable findTable;
    private javax.swing.JLabel findZipCodeLabel;
    private javax.swing.JSpinner findZipCodeSpinner;
    private javax.swing.JButton getButton;
    private javax.swing.JLabel getCustomerLabel;
    private java.awt.Panel getCustomerPanel;
    private javax.swing.JLabel getIDLabel;
    private javax.swing.JSpinner getIDSpinner;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JRadioButton privateCustomerRB;
    // End of variables declaration//GEN-END:variables
}